
#######################################################
# ********************* 画面实现 ********************* #
#######################################################
FormLayout:
  name: 'ticket_page'
  font_size: 28
  canvas:
    Rectangle:
      size: self.size
      pos: self.pos
      source: app.ConfigComm.IMG_AZURE # 引用图片路径设置背景图
  AnchorLayout:
    anchor_x: "center"
    anchor_y: "center"
    canvas.before:
      Color:
        rgba: 1, 0, 0, .9  # 设置颜色为红色
      Line:
        width: 1  # 设置边框宽度
        rectangle: self.x, self.y, self.width, self.height
    BoxLayout:
      size_hint: 0.9, 0.9
      orientation: "vertical"
      canvas.before:
        Color:
          rgba: 1, 0, 0, .9  # 设置颜色为红色
        Line:
          width: 1  # 设置边框宽度
          rectangle: self.x, self.y, self.width, self.height
      RowLayout:
        ColLayout:
          size_hint_x: None
          width: 130
          LabelComm:
            text: "手机："
        ColLayout:
          TextInputComm:
            id: tel
      RowLayout:
        ColLayout:
          size_hint_x: None
          width: 130
          LabelComm:
            text: "模式："
        ColLayout:
          id: pattern
          CheckBoxComm:
            group: 'pattern'    # 设置group就变成单选框
            id: grap
            text: '00'
            #on_active: root.pattern_check(self)
          LabelComm:
            text: '抢票'
            size_hint_x: None
            width: 50
            on_touch_down:
              if self.collide_point(*args[1].pos): grap.active = not grap.active  # 使点label也能切换状态
          CheckBoxComm:
            group: 'pattern'    # 设置group就变成单选框
            id: monitor
            text: '01'
            #on_active: root.pattern_check(self)
          LabelComm:
            text: '监控'
            size_hint_x: None
            width: 50
            on_touch_down:
              if self.collide_point(*args[1].pos): monitor.active = not monitor.active   # 使点label也能切换状态
      RowLayout:
        ColLayout:
          size_hint_x: None
          width: 130
          LabelComm:
            text: "执行时间："
        ColLayout:
          LabelComm:
            text: '时'
            size_hint_x: None
            width: 20
          SpinnerComm:
            id: time_hour
            size_hint_x: None
            width: "40"
            color: (1, 0, 0, 1)
            background_normal: app.ConfigComm.IMG_BUTTON_COMM_FORM
            background_down: app.ConfigComm.IMG_BUTTON_COMM_FORM
            values: [ "{:02d}".format(i) for i in range(24) ]  # 小时选择范围
          LabelComm:
            text: '分'
            size_hint_x: None
            width: 20
          SpinnerComm:
            id: time_minute
            size_hint_x: None
            width: "40"
            color: (1, 0, 0, 1)
            background_normal: app.ConfigComm.IMG_BUTTON_COMM_FORM
            background_down: app.ConfigComm.IMG_BUTTON_COMM_FORM
            values: [ "{:02d}".format(i) for i in range(60) ]  # 分钟选择范围
          LabelComm:
            text: '秒'
            size_hint_x: None
            width: 20
          SpinnerComm:
            id: time_second
            size_hint_x: None
            width: "40"
            color: (1, 0, 0, 1)
            background_normal: app.ConfigComm.IMG_BUTTON_COMM_FORM
            background_down: app.ConfigComm.IMG_BUTTON_COMM_FORM
            values: [ "{:02d}".format(i) for i in range(60) ]  # 秒钟选择范围
      RowLayout:
        ColLayout:
          size_hint_x: None
          width: 130
          LabelComm:
            text: "策略："
        ColLayout:
          id: strategy
          CheckBoxComm:
            group: 'strategy'    # 分组名
            id: strategy_00  # 添加ID属性
            text: '00'
            on_active: root.strategy_check(self)
          LabelComm:
            text: '日期'
            size_hint_x: None
            width: 50
            on_touch_down:
              if self.collide_point(*args[1].pos): strategy_00.active = not strategy_00.active  # 使点label也能切换状态
          CheckBoxComm:
            group: 'strategy'    # 分组名
            id: strategy_01  # 添加ID属性
            text: '01'
            on_active: root.strategy_check(self)
          LabelComm:
            text: '天'
            size_hint_x: None
            width: 50
            on_touch_down:
              if self.collide_point(*args[1].pos): strategy_01.active = not strategy_01.active  # 使点label也能切换状态
          CheckBoxComm:
            group: 'strategy'    # 分组名
            id: strategy_02  # 添加ID属性
            text: '02'
            on_active: root.strategy_check(self)
          LabelComm:
            text: '周'
            size_hint_x: None
            width: 50
            on_touch_down:
              if self.collide_point(*args[1].pos): strategy_02.active = not strategy_02.active  # 使点label也能切换状态
      RowLayout:
        ColLayout:
          size_hint_x: None
          width: 130
          LabelComm:
            text: "策略值："
        ColLayout:
          BoxLayout:
            ButtonForm:
              padding: 5, 5, 5, 5
              size_hint_x: 1
              color: 1, 0, 0, 1  # 设置文字颜色为红色
              id: strategy_vals
              text: "请选择策略值"
              text_size: self.size
              halign: 'left'
              valign: 'middle'
              dropdown: strategy_vals_dropdown.__self__  # 保证对下拉框的引用，防止被gc回收
              on_parent: strategy_vals_dropdown.dismiss()
              on_release: strategy_vals_dropdown.open(self)
            MultiSelectDropDown:
              id: strategy_vals_dropdown
              main_button: strategy_vals
#              options: [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15' ]
      RowLayout:
        ColLayout:
          size_hint_x: None
          width: 130
          LabelComm:
            text: "门票场地："
        ColLayout:
          BoxLayout:
            ButtonForm:
              padding: 5, 5, 5, 5
              size_hint_x: 1
              color: 1, 0, 0, 1  # 设置文字颜色为红色
              id: ground_nos
              text: "请选择门票场地"
              text_size: self.size
              halign: 'left'
              valign: 'middle'
              dropdown: ground_nos_dropdown.__self__  # 保证对下拉框的引用，防止被gc回收
              on_parent: ground_nos_dropdown.dismiss()
              on_release: ground_nos_dropdown.open(self)
            MultiSelectDropDown:
              id: ground_nos_dropdown
              main_button: ground_nos
              options: [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15' ]

      RowLayout:
        ColLayout:
          size_hint_x: None
          width: 130
          LabelComm:
            text: "门票时间："
        ColLayout:
          BoxLayout:
            ButtonForm:
              padding: 5, 5, 5, 5
              size_hint_x: 1
              color: 1, 0, 0, 1  # 设置文字颜色为红色
              id: ground_times
              text: "请选择门票时间"
              text_size: self.size
              halign: 'left'
              valign: 'middle'
              dropdown: ground_times_dropdown.__self__  # 保证对下拉框的引用，防止被gc回收
              on_parent: ground_times_dropdown.dismiss()
              on_release: ground_times_dropdown.open(self)
            MultiSelectDropDown:
              id: ground_times_dropdown
              main_button: ground_times
              options: [ '09:00-10:00', '10:00-11:00', '11:00-12:00', '12:00-13:00', '13:00-14:00', '14:00-15:00', '15:00-16:00', '16:00-17:00' ]

      RowLayout:
        ColLayout:
          spacing: 10
          ButtonComm:
            text: "全删"
            on_release: root.delete_all()
          ButtonComm:
            text: "load"
            on_release: root.load_tickets_file()
          ButtonComm:
            text: "dump"
            on_release: root.dump_ticket_file()
          ButtonComm:
            text: "刷新"
            on_release: root.refresh()
          ButtonComm:
            text: "赋值"
            on_release: root.setval()
      RowLayout:
        ColLayout:
          spacing: 10
          padding: self.width*0.5-180, 0, 0, 5
          ButtonComm:
            id: commit
            text: "保存"
            on_release: root.commit_form()
          ButtonComm:
            id: reset
            text: "重置"
            on_release: root.reset_form()

      BoxLayout:
        orientation: 'vertical'
        RowLayout:
          CellLayout:
            size_hint_x: None
            width: root.cell_width.get('id')
            text: "序号"
          CellLayout:
            size_hint_x: None
            width: root.cell_width.get('tel')
            text: "手机"
          CellLayout:
            size_hint_x: None
            width: root.cell_width.get('pattern')
            text: "模式"
          CellLayout:
            size_hint_x: None
            width: root.cell_width.get('begin_time')
            text: "执行时间"
          CellLayout:
            size_hint_x: None
            width: root.cell_width.get('strategy')
            text: "策略"
          CellLayout:
            text: "策略值"
          CellLayout:
            text: "门票场地"
          CellLayout:
            text: "门票时间"
          CellLayout:
            size_hint_x: None
            width: root.cell_width.get('operate')
            text: "操作"
        ScrollView:
          size_hint: (1, 1)  # 占满父组件
          do_scroll_x: False  # 禁止水平滚动
          do_scroll_y: True   # 启用垂直滚动
          bar_width: 10
          bar_color: .5,.5,.5,.7
          BoxLayout:
            id: ticket_content
            size_hint_y: None  # 禁用 Y 方向的大小提示
            height: self.minimum_height  # 设置高度为内容的最小高度
            orientation: 'vertical'
            BoxLayout:
              id: ticket_blank
              size_hint_y: None  # 禁用 Y 方向的大小提示
              height: self.minimum_height  # 设置高度为内容的最小高度
              LabelComm:
                size_hint: 1,None
                height: 80
                halign: 'center'
                text: "无数据"
            BoxLayout:
              id: ticket_table
              size_hint_y: None  # 禁用 Y 方向的大小提示
              height: self.minimum_height  # 设置高度为内容的最小高度
              orientation: 'vertical'
#              RowLayout:
#                LabelComm:
#                  text: "id"
#                LabelComm:
#                  text: "var1"
#                LabelComm:
#                  text: "var2"
#                LabelComm:
#                  text: "var3"
#                LabelComm:
#                  text: "var4"
#                LabelComm:
#                  text: "var5"
#                LabelComm:
#                  text: "var5"
#                LabelComm:
#                  text: "var7"


